const fp = require('lodash/fp')
const {
    Maybe,
    Container
} = require("./support")

const maybe = Maybe.of([5, 6, 1])

const xs = Container.of(["do", "ray", "me", "fa", "so", "la", "ti", "do"])

// test one
const ex1 = (data, x) => {
    return fp.map((item) => fp.add(x, item), data)
}

maybe.map(value => ex1(value, 2))
    .map(console.log)

// test two
const ex2 = (data) => {
    return fp.first(data)
}

xs.map(ex2)
    .map(console.log)


// test three
const safeProp = fp.curry((x, o) => Maybe.of(o[x]))
const user = {
    id: 2,
    name: "Albert"
}

const ex3 = (obj, prop) => {
    return safeProp(prop, obj).map(fp.first)._value
}

const res= ex3(user, "name")
console.log(res)


// test four
let ex4 = (n) => {
    if (n) {
        return parseInt(n)
    }
}


ex4 = (n) =>{
    return Maybe.of(n).map(parseFloat)._value
}


const value = ex4(1)
console.log(value)